#pragma once
#include "Integer.h"

class Rational
{
private:
	Integer numerator;
	Integer denominator;
public:
	Rational() : numerator(0), denominator(1) {}
	Rational(const Integer &numerator, const Integer &denominator, bool coprime = false);
	Rational(const Integer &n): numerator(n), denominator(1) {}
	Rational(const int n): numerator(n), denominator(1) {}
	Rational(const unsigned n): numerator(n), denominator(1) {}
public:
	const Integer Numerator() const;
	const Integer& Denominator() const;
	std::string str() const;
	friend std::ostream& operator<<(std::ostream &out, const Rational &r);
	friend bool operator==(const Rational &lhs, const Rational &rhs);
	friend bool operator!=(const Rational &lhs, const Rational &rhs);
	friend bool operator<(const Rational &lhs, const Rational &rhs);
	friend bool operator<=(const Rational &lhs, const Rational &rhs);
	friend bool operator>(const Rational &lhs, const Rational &rhs);
	friend bool operator>=(const Rational &lhs, const Rational &rhs);
	Rational operator-() const;
	friend Rational Inverse(const Rational &r);
	friend Rational operator+(const Rational &lhs, const Rational &rhs);
	Rational& operator+=(const Rational &addend);
	friend Rational operator-(const Rational &lhs, const Rational &rhs);
	Rational& operator-=(const Rational &subtrahend);
	friend Rational operator*(const Rational &lhs, const Rational &rhs);
	Rational& operator*=(const Rational &addend);
	friend Rational Square(const Rational &n);
	friend Rational operator/(const Rational &lhs, const Rational &rhs);
	Rational& operator/=(const Rational &divisor);
};

